package oldCodePackage;
import java.util.Random;


public class Deck {
	static final private int NUM_SUITS = 4;
	static final private int NUM_VALUES = 13;
	static final private int NUM_CARDS = NUM_SUITS * NUM_VALUES;
	
	private Random generator = new Random();
	
	private Card cardsInDeck[] = new Card[NUM_CARDS];
	private boolean cardsUsed[] = new boolean[NUM_CARDS];
	
	Deck(){
		int curCard = 0;
		
		for(int suit=1; suit<NUM_SUITS+1; suit++){//adds all the cards to the deck, suits 1-4, values 1-13
			for(int value=1; value<NUM_VALUES+1; value++){
				cardsInDeck[curCard] = new Card(suit, value);
				curCard++;
			}
		}
	}
	
	//deal out a hand of x size
	public Card[] dealHand(int handSize){
		Card hand[] = new Card[handSize];
		int randomIndex = 0;
		
		for(int i=0; i<=handSize; i++){
			do{
				randomIndex = generator.nextInt(NUM_CARDS);
			}while(cardsUsed[randomIndex]); //do until a new card is found
			
			cardsUsed[randomIndex] = true; //set card to used
			hand[i] = cardsInDeck[randomIndex]; //add card to hand
		}
		
		return hand;
	}
	
	//clear used cards
	public void shuffleCards(){
		for(int i=0; i<NUM_CARDS; i++)
			cardsUsed[i] = false;
	}

}
